package com.lsk.apipassenger.service;

import com.lsk.apipassenger.remote.ServicePriceClient;
import com.lsk.internalcommon.DTO.ResponseResult;
import com.lsk.internalcommon.request.ForecastPriceDTO;
import com.lsk.internalcommon.response.ForecastPriceResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class ForecastPriceService {
    @Autowired
    private ServicePriceClient servicePriceClient;

    public ResponseResult forecastPrice(String deplongitude,String deplatitude,String destlongitude,String destlatitude,String cityCode,String vehicleType){
        log.info("出发地经度："+deplongitude);
        log.info("出发地纬度："+deplatitude);
        log.info("目的地经度："+destlongitude);
        log.info("目的地纬度："+destlatitude);

        log.info("调用预估价格服务");
        ForecastPriceDTO forecastPriceDTO = new ForecastPriceDTO();
        forecastPriceDTO.setDeplongitude(deplongitude);
        forecastPriceDTO.setDeplatitude(deplatitude);
        forecastPriceDTO.setDestlongitude(destlongitude);
        forecastPriceDTO.setDestlatitude(destlatitude);
        forecastPriceDTO.setCityCode(cityCode);
        forecastPriceDTO.setVehicleType(vehicleType);

        ResponseResult<ForecastPriceResponse> result = servicePriceClient.forecastPrice(forecastPriceDTO);
        double price = result.getData().getPrice();

        ForecastPriceResponse priceResponse = new ForecastPriceResponse();
        priceResponse.setPrice(price);
        priceResponse.setCityCode(cityCode);
        priceResponse.setVehicleType(vehicleType);
        return ResponseResult.success(priceResponse);
    }
}
